package edu.scau.hot.service.impl;

import edu.scau.hot.entity.HotDiscount;
import edu.scau.hot.mapper.HotDiscountMapper;
import edu.scau.hot.service.IHotDiscountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotDiscount)表服务实现类
 *
 * @author PaperEasyCode
 * @since 2022-03-02 15:25:26
 */
@Service("hotDiscountService")
public class HotDiscountServiceImpl implements IHotDiscountService{
    @Resource
    private HotDiscountMapper hotDiscountMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param discountId 主键
     * @return 实例对象
     */
    @Override
    public HotDiscount queryById(Integer discountId) {
        return this.hotDiscountMapper.queryById(discountId);
    }

    /**
     * 查询所有数据
     *
     * @param hotDiscount 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotDiscount> queryAll(HotDiscount hotDiscount) {
        return this.hotDiscountMapper.queryAll(hotDiscount);
    }

    /**
     * 新增数据
     *
     * @param hotDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotDiscount insert(HotDiscount hotDiscount) {
        this.hotDiscountMapper.insert(hotDiscount);
        return hotDiscount;
    }

    /**
     * 修改数据
     *
     * @param hotDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotDiscount update(HotDiscount hotDiscount) {
        this.hotDiscountMapper.update(hotDiscount);
        return this.queryById(hotDiscount.getDiscountId());
    }

    /**
     * 通过主键删除数据
     *
     * @param discountId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer discountId) {
        return this.hotDiscountMapper.deleteById(discountId) > 0;
    }
}
